﻿using System;
using System.Web.UI;
using umbraco.NodeFactory;

namespace UComment.Usercontrols
{
    public partial class AjaxCommentForm : UserControl
    {
        public bool RegisterScripts { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (RegisterScripts)
            {
                umbraco.library.AddJquery();
                umbraco.library.RegisterJavaScriptFile("jquery_form", ResolveClientUrl("~/scripts/UComment/jquery.form.js"));
                umbraco.library.RegisterJavaScriptFile("jquery_metadata", ResolveClientUrl("~/scripts/UComment/jquery.metadata.js"));
                umbraco.library.RegisterJavaScriptFile("jquery_validate", ResolveClientUrl("~/scripts/UComment/jquery.validate.min.js"));
            }

            if (Page.IsPostBack)
            {
                Library.Base.CreateComment(Node.GetCurrent().Id);
            }
        }
    }
}